import http from './http';
import axios from 'axios';

const requestProxy = {
  post: (url, data = {}, onSetCancelToken) => {
    if (!onSetCancelToken) {
      // return http.post(url, { data: JSON.stringify(data) });
      return http.post(url, data);
    }
    // return http.post(url, { data: JSON.stringify(data) }, { cancelToken: new axios.CancelToken((cancelFun) => { onSetCancelToken(cancelFun); }) },
    return http.post(url, data, { cancelToken: new axios.CancelToken((cancelFun) => { onSetCancelToken(cancelFun); }) },
    );
  },
  request: http
};

export default requestProxy;
